//
//  GKBComboBoxDataSource.m
//  Pennyworth
//
//  Created by Chris Karr on 2/9/08.
//  Copyright 2008 Chris J. Karr. All rights reserved.
//

#import "GKBComboBoxDataSource.h"


@implementation GKBComboBoxDataSource

- (NSUInteger) comboBox:(NSComboBox *) aComboBox indexOfItemWithStringValue:(NSString *) aString
{
	return [[controller arrangedObjects] indexOfObject:aString];
}

- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index
{
	return [[controller arrangedObjects] objectAtIndex:index];
}

- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
	return [[controller arrangedObjects] count];
}

- (NSString *) comboBox:(NSComboBox *) aComboBox completedString:(NSString *) completedString
{
	NSArray * list = [controller arrangedObjects];

	for (NSString * value in list)
		if ([[value lowercaseString] hasPrefix:[completedString lowercaseString]])
			return value;

	return @"";
}

@end
